package org.x.user.enums;



public enum UserTypeEnum {

    /**
     * 管理员
     */
    ADMIN("ADMIN", "管理员"),

    /**
     * 律师
     */
    LAWYER("LAWYER", "律师"),

    /**
     * 普通用户
     */
    USER("USER", "普通用户");

    private final String code;
    private final String description;

    UserTypeEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据code获取枚举值
     *
     * @param code 用户类型编码
     * @return 枚举值
     */
    public static UserTypeEnum fromCode(String code) {
        for (UserTypeEnum userType : values()) {
            if (userType.getCode().equals(code)) {
                return userType;
            }
        }
        throw new IllegalArgumentException("无效的用户类型：" + code);
    }
}

